//
//  WmcMyCouldAblumCell.swift
//  YPWatermarkCamera
//
//  Created by yupao_ios_macmini06 on 2022/9/15.
//

import UIKit

/// 同步状态
enum WmcCloudSynStatus {
    // 开启
    case opend
    // 未开启
    case closed
}

extension WmcCloudSynStatus {
    var info: (textColor: UIColor, bgColor: UIColor) {
        switch self {
        case .opend:
            return (UIColor.wmc_blue_5290FD, UIColor.wmc_blue_5290FD.withAlphaComponent(0.1))
        case .closed:
            return (UIColor.wmc_red_F54A45, UIColor.wmc_red_F54A45.withAlphaComponent(0.1))
        }
    }

    var title: String {
        switch self {
        case .opend:
            return "已开启同步"
        case .closed:
            return "未开启同步"
        }
    }
}

class WmcSynTagLabel: WmcPaddingLabel {
    var status: WmcCloudSynStatus? {
        didSet {
            guard let status = status else {
                return
            }
            label.textColor = status.info.textColor
            backgroundColor = status.info.bgColor
            label.text = status.title
        }
    }
}

/// 团队相册 cell
class WmcMyTeamCloudAblumCell: WmcMyClouddAblumCell {
    override func makeUI() {
        super.makeUI()

        // contentView.addSubview(synTagLabel)
        contentView.addSubview(bottomNoteLabel)

        mainTitleLabel.snp.remakeConstraints { make in
            make.top.equalTo(7)
            make.height.equalTo(21)
            make.left.equalTo(avatarView.snp.right).offset(12)
            make.width.lessThanOrEqualTo(170 * 375 / Wmc_screenWidth)
        }

        subTitleLabel.snp.remakeConstraints { make in
            make.centerY.equalToSuperview()
            make.left.equalTo(avatarView.snp.right).offset(12)
        }

        synTagLabel.snp.makeConstraints { make in
            make.centerY.equalTo(mainTitleLabel.snp.centerY)
            make.left.equalTo(mainTitleLabel.snp.right).offset(16)
        }

        bottomNoteLabel.snp.makeConstraints { make in
            make.left.equalTo(subTitleLabel.snp.left)
            make.bottom.equalTo(-7)
        }

        subTitleLabel.textColor = UIColor.wmc_grayH8_8A8A99
        subTitleLabel.font = 12.yp.uiFont
    }

    override func configure(model: WmcMediaTeamAlbumModel) {
        mainTitleLabel.text = model.name
        subTitleLabel.text = "团队号：\(model.teamOpenId)"
        bottomNoteLabel.text = "今日\(model.currentDateAuthorNum)人拍照，共\(model.currentDateResourceNum)张"
        let member = WmcTeamMember(name: model.name, img: nil)
        avatarView.member = member
        synTagLabel.status = model.isSync ? .opend : .closed
        redDotView.isHidden = !model.isShowRedDot

        print("team === \(model.isShowRedDot)")
    }

    lazy var bottomNoteLabel: UILabel = {
        let view = UILabel()
        view.textColor = UIColor.wmc_grayH8_8A8A99
        view.font = 12.yp.uiFont
        return view
    }()
}
